package spilder;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.IOException;

public class Main {
    public static void main(String[]args) throws IOException, InterruptedException {
        Spilder spilder = new Spilder();
        for(int i=0;i<99;i++){
            Thread.sleep(1000);
            String str = spilder.downLoad("https://sclub.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98vv33490&productId=7437780&score=0&sortType=5&page="+i+"&pageSize=10&isShadowSku=0&fold=1");
            System.out.println(i);
            String substring = str.substring(str.indexOf("(") + 1, str.lastIndexOf(")"));
            JSONObject object = (JSONObject) Utils.getObject(substring);
            JSONArray comments = (JSONArray)object.get("comments");
            for (int j =0;j<comments.length();j++){
                JSONObject comment = (JSONObject)comments.get(j);
                String content = comment.getString("content").replaceAll("[^\\u4e00-\\u9fa5]", "");
                Utils.toAnalysis(content);
            }
        }
    }
}
